home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Programming / ace_gpl_release / src / ace / c / iff.c < prev    next >
Encoding:
C/C++ Source or Header  |  1998-10-04  |  2.8 KB  |  169 lines

  1. /*
  2. ** ACE IFF commands.
  3. ** Copyright (C) 1998 David Benn
  4. ** 
  5. ** This program is free software; you can redistribute it and/or
  6. ** modify it under the terms of the GNU General Public License
  7. ** as published by the Free Software Foundation; either version 2
  8. ** of the License, or (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program; if not, write to the Free Software
  17. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  18. **
  19. ** Author: David J Benn
  20. **   Date: 27th February 1994,
  21. **       10th,11th,19th August 1994
  22. */
  23.  
  24. #include "acedef.h"
  25.  
  26. /* externals */
  27. extern    int    sym;
  28. extern    BOOL    iffused;
  29.  
  30. /* functions */
  31. void    iff_open()
  32. {
  33. /* 
  34. ** IFF OPEN [#]channel,file-name
  35. */
  36. int    itype;
  37.  
  38.     insymbol();
  39.  
  40.     if (sym == hash) insymbol();
  41.  
  42.     itype = expr();
  43.  
  44.     if (itype == stringtype)
  45.         _error(4);
  46.     else
  47.     {
  48.         /* channel */
  49.         if (make_integer(itype) == shorttype) make_long();
  50.         
  51.         if (sym != comma) 
  52.             _error(16);
  53.         else
  54.         {
  55.             /* picture file name */
  56.             insymbol();
  57.             if (expr() != stringtype)
  58.                 _error(4);
  59.             else
  60.             {
  61.                 /* call function */
  62.                 gen("jsr","_IFFPicOpen","  ");
  63.                 gen("addq","#8","sp");
  64.                 enter_XREF("_IFFPicOpen");
  65.             }                
  66.         } 
  67.             
  68.     }
  69. }
  70.  
  71. void    iff_read()
  72. {
  73. /* 
  74. ** IFF READ [#]channel[,screen-id]
  75. */
  76. int    itype;
  77.  
  78.     insymbol();
  79.  
  80.     if (sym == hash) insymbol();
  81.  
  82.     itype = expr();
  83.  
  84.     if (itype == stringtype)
  85.         _error(4);
  86.     else
  87.     {
  88.         /* channel */
  89.         if (make_integer(itype) == shorttype) make_long();
  90.  
  91.         if (sym != comma)
  92.             /* no screen-id */
  93.             gen("move.l","#-1","-(sp)");    
  94.         else
  95.         {
  96.             /* screen-id */
  97.  
  98.             insymbol();
  99.             
  100.             itype = expr();
  101.  
  102.             if (itype == stringtype)
  103.                 _error(4);
  104.             else
  105.             {
  106.                 if (make_integer(itype) == shorttype) 
  107.                    make_long();
  108.  
  109.             }
  110.         }
  111.  
  112.         /* call function */
  113.         gen("jsr","_IFFPicRead","  ");
  114.         gen("addq","#8","sp");
  115.         enter_XREF("_IFFPicRead");
  116.     }
  117. }
  118.  
  119. void    iff_close()
  120. {
  121. /* 
  122. ** IFF CLOSE [#]channel
  123. */
  124. int    itype;
  125.  
  126.     insymbol();
  127.  
  128.     if (sym == hash) insymbol();
  129.  
  130.     itype = expr();
  131.  
  132.     if (itype == stringtype)
  133.         _error(4);
  134.     else
  135.     {
  136.         /* channel */
  137.         if (make_integer(itype) == shorttype) make_long();
  138.  
  139.         /* call function */
  140.         gen("jsr","_IFFPicClose","  ");
  141.         gen("addq","#4","sp");
  142.         enter_XREF("_IFFPicClose");
  143.     }
  144. }
  145.  
  146. void iff()
  147. {
  148. /* IFF OPEN | READ | CLOSE */
  149.  
  150.     insymbol();
  151.     
  152.     switch(sym)
  153.     {
  154.         case opensym  : iff_open(); break;
  155.         case readsym  : iff_read(); break;
  156.         case closesym : iff_close(); break;
  157.     }
  158.  
  159.     /* 
  160.     ** All three require intuition.library.
  161.     */
  162.     enter_XREF("_IntuitionBase");
  163.  
  164.     /*
  165.     ** We need to tell ACE to create/delete ILBM.library.
  166.     */
  167.     iffused = TRUE;
  168. }
  169.